package practice1_100;

import java.util.Arrays;
import java.util.Comparator;

public class Practice179 {
    public String largestNumber(int[] nums) {
        String[] strings=new String[nums.length];
        int i=0;
        String res="";
        for (int num:nums ) {
            strings[i]=num+"";
            i++;
        }

        Arrays.sort(strings, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                if(Long.parseLong(o1+o2)>Long.parseLong(o2+o1))
                    return 1;
                else return -1;
            }
        });
        if(strings[0].equals("0")) return "0";
        for (String temp:strings) {
            res+=temp;
        }
        return res;
    }

    public static void main(String[] args) {
        String a= new Practice179().largestNumber(new int[]{43,63,43,2,2,15,4,5,32,5,6,23,6,26,56,2,65,2,68,6,97,696,9,6,96,9,4,9,9,4,5,7,2,2});

    }
}
